package com.huluobo.a2203parkdemo.patrol

import androidx.lifecycle.MutableLiveData
import com.huluobo.base.mvvm.BaseViewModel
import com.huluobo.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import okhttp3.RequestBody
import javax.inject.Inject

/**
 *  Created by LC on 2024/8/1.
 */
@HiltViewModel
class PatrolViewModel @Inject constructor(
    val apiService: ApiService
) : BaseViewModel() {
    val getAllPatrolsSuccess by lazy { MutableLiveData<String>() }

    fun getAllPatrols() {
        executeNetRequest(
            { apiService.getAllPatrols() },
            getAllPatrolsSuccess::postValue
        )
    }

    val getAllPointSuccess by lazy { MutableLiveData<String>() }

    fun getAllPoint() {
        executeNetRequest(
            { apiService.getAllPoint() },
            getAllPointSuccess::postValue
        )
    }

    val addPointSuccess by lazy { MutableLiveData<String>() }

    fun addPoint(body: RequestBody) {
        executeNetRequest(
            { apiService.addPoint(body) },
            addPointSuccess::postValue
        )
    }

    val addPatrolSuccess by lazy { MutableLiveData<String>() }
    fun addPatrol(body: RequestBody) {
        executeNetRequest(
            { apiService.addPatrol(body) },
            addPatrolSuccess::postValue
        )
    }
}